<include file="Public:mainHeader" />
<style>
.added , .delete{background: none repeat scroll 0 0 #F0F0F0;
    border: 1px solid #E5E5E5;
    color: #444444;
    height: 23px;
    line-height: 23px;
    text-align: center;
    top: 0;
    width: 17px;}
.item-amount a:hover{ border-color:#FF0000; color:#FF0000;text-decoration:none;}
</style>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0" class="mart15">
  <tr>
    <td width="4"><img src="__IMG_ADMIN_PATH__/gk1.png" width="4" height="39" /></td>
    <td background="__IMG_ADMIN_PATH__/gk2.png"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="23" class="xtgk2"><img src="__IMG_ADMIN_PATH__/gk_1.png" width="16" height="16" /></td>
          <td class="xtgk1">{$tabNum}号桌位详情</td>
        </tr>
      </table></td>
    <td width="5"><img src="__IMG_ADMIN_PATH__/gk3.png" width="5" height="39" /></td>
  </tr>
</table>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#dca581">
  <tr>
    <td bgcolor="#FFFFFF"><table width="95%" id="mytable" border="0" align="center" cellpadding="10" cellspacing="1" bgcolor="#efddd2" class="mart15 marb15 color333">
        <tr>
          <td align="center" bgcolor="#f5ede6"><h1>序号</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>菜名</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>缩略图</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>价格</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>数量</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>状态</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>操作</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>总计</h1></td>
        </tr>
        <volist name="list" id="v">
          <tr>
            <td align="center">{$key+1}</td>
            <td align="center">{$v.name}</td>
            <td align="center"><img src="{$v.pic}" width="100"  height="100"/></td>
            <td align="center"><font class="price">{$v.price}</font>元</td>
            <td align="center"><div class="item-amount amountUpdate" style="display:none"><a class="delete" href="#">-</a>
                <input class="amountVal" type="text" disabled="disabled" autocomplete="off" data-now="2" style="background-color: #FFFFFF; background-position: -75px -375px; border: 1px solid #AAAAAA; color: #343434; height: 15px; left: 18px; line-height: 15px; padding: 4px 0; text-align: center; top: 0; width: 30px;" data-max="2"  value="{$v.amount}">
                <a class="added" href="#">+</a></div><font class="amountOriginal" style=" margin-right:20px;">{$v.amount}</font><font>[<a href="javascript:void(0);" dataid="{$v.id}" typeid="1" onclick="amount(this);">修改</a>]</font>
				</td>
            <td align="center">&nbsp;&nbsp;&nbsp;&nbsp;<if condition="$v['check'] eq 2"><font color="#008000">已下单</font>&nbsp;&nbsp;&nbsp;&nbsp;<elseif condition="$v['check'] eq 1" /><font color="#008000">请求下单</font>&nbsp;&nbsp;&nbsp;&nbsp;<else /><font color="red">待下单</font>&nbsp;&nbsp;&nbsp;&nbsp;</if></font><if condition="$v['status'] eq 1">&nbsp;&nbsp;&nbsp;&nbsp;<font color="red">[追加]</font></if></td>
            <td align="center"><a href="javascript:confirmurl('/index.php?g=Admin&m=Index&a=delTempTab&id={$v.id}','你确定要删除吗？');">删除</a></td>
            <td align="center"><font class="partPrice">{$v.allPrice}</font>元</td>
          </tr>
        </volist>
        <tr>
          <td colspan="6" align="right" ><a href="/index.php?g=Admin&m=Index&a=printer&t_id={$v.t_id}#btn"  class="fancybox fancybox.iframe" >打印预览</a><font style="margin-left:50px;">小计：</font></td>
          <td align="center" class="colorf00 fontweight"><font id="allPrice">{$allPrice}</font>元</td>
        </tr>
      </table>
      <div style=" color: #FF6500; font-size: 14px; margin: 3px 3px 15px; padding: 3px; text-align: center;"> {$page} </div><if condition="$settleInfo"><div style=" color: #FF6500; font-size: 22px; padding: 3px; text-align:left; margin-left:10%;">{$settleInfo.createtime|time_ago}&nbsp; <eq name="settleInfo['type']" value='1'>(请求下单)</eq><eq name="settleInfo['type']" value='2'>(请求结账)</eq></div></if><div style=" color: #FF6500; font-size: 14px; margin: 3px 30% 15px; padding: 3px; text-align:right;"><input style="margin-right:50px;" type="button" class="input10" value="确认下单"  onclick="confirmurl('/index.php?g=Admin&m=Index&a=order&t_id={$v.t_id}','您确定下单吗？');" /><input type="button" class="input10" value="确认结账"  onclick="confirmurl('/index.php?g=Admin&m=Index&a=settle&t_id={$v.t_id}','您确定结账吗？');" /></div></td>
  </tr>
</table>
</td>
</tr>
</table>
<script>
	//减少按钮绑定事件	  added by Tony
	$('.delete').click(function(){
		var amountVal = parseInt($(this).siblings('.amountVal').val());
		if(amountVal > 1){
			var amount = amountVal-1*1;
			$(this).siblings('.amountVal').val(amount);
		}
	});
	//增加按钮绑定事件	  added by Tony
	$('.added').click(function(){
		var amountVal = parseInt($(this).siblings('.amountVal').val());
		var amount = amountVal+1*1;
		$(this).siblings('.amountVal').val(amount);
	});
	//使用中餐桌某商品数量更改  added by Tony
	function amount(that){
		var type = $(that).attr('typeid');
		var id = $(that).attr('dataid');
		var amountOriginal = parseInt($(that).parent().siblings('.amountOriginal').html());
		if(type == 1){
			$(that).parent().siblings('.amountUpdate').show();
			$(that).parent().siblings('.amountOriginal').hide();
			$(that).attr('typeid',2).html('确定');
		}else if(type == 2){
			var amountVal = parseInt($(that).parent().siblings().find('.amountVal').val());
			if(amountOriginal != amountVal){
				if(confirm('你确定要修改吗？')){
					var price = parseInt($(that).parent().parent().siblings().find('.price').html());
					var oldPartPrice = parseInt($(that).parent().parent().siblings().find('.partPrice').html());
					var allPrice = parseInt($('#allPrice').html());
					var parPrice = (price*amountVal).toFixed(2);
					var nowAllPrice = (allPrice+(parPrice-oldPartPrice)).toFixed(2);
					$.post("/index.php?g=Admin&m=Index&a=updateTempTab",{'id':id,'amount':amountVal},function(re){
						if(re.status == 1){
							$(that).parent().siblings('.amountOriginal').html(amountVal);
							$(that).parent().parent().siblings().find('.partPrice').html(parPrice)
							$('#allPrice').html(nowAllPrice);
						}else{
							alert('修改失败！');
						}
					},'json');
				}else{
					$(that).parent().siblings().find('.amountVal').val(amountOriginal);
				}
			}
			$(that).parent().siblings('.amountUpdate').hide();
			$(that).parent().siblings('.amountOriginal').show();
			$(that).attr('typeid',1).html('修改');
		}
	}
</script>
<include file="Public:mainFooter" />